<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增商品管理')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-goods-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">商品名称：</label>
                <div class="col-sm-8">
                    <textarea name="goodsName" class="form-control" required></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商品描述：</label>
                <div class="col-sm-8">
                    <textarea name="goodsDesc" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">商品价格：</label>
                <div class="col-sm-8">
                    <input name="goodsPrice" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品市场价：</label>
                <div class="col-sm-8">
                    <input name="goodsMaketPrice" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品库存：</label>
                <div class="col-sm-8">
                    <input name="goodsStock" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品图片链接：</label>
                <div class="col-sm-8">
                    <input name="goodsImg" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品上架时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="goodsSellTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">商品状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('goods_status')}">
                        <input type="radio" th:id="${'goodsStatus_' + dict.dictCode}" name="goodsStatus" th:value="${dict.dictValue}" th:checked="${dict.default}" required>
                        <label th:for="${'goodsStatus_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">供应商：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <select name="supplierId" class="form-control m-b" required>-->
<!--                        <option value="1">1</option>-->
<!--                        <option value="2">2</option>-->
<!--                    </select>-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">供应商：</label>
                <div class="col-xs-4">
                    <select name="supplierId" id="supplier" class="form-control m-b select2-multiple">
                        <option th:each="supplier:${suppliers}" th:value="${supplier.supplierId}" th:text="${supplier.supplierName}" th:disabled="${supplier.supplierStatus == '1'}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/goods"
        $("#form-goods-add").validate({
            focusCleanup: true,
            rules:{
                goodsStock: {
                    required: true,
                    digits: true
                }
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-goods-add').serialize());
            }
        }

        $("input[name='goodsSellTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>